package com.shijun.config;

import android.content.Context;
import android.view.ViewGroup;

import com.shijun.bean.ConfigModle;
import com.shijun.bean.GroupModle;
import com.shijun.bean.ImageModle;
import com.shijun.pullrecyclerviewdemo.R;

import java.util.List;

/**
 * Created by zhushijun on 2017/12/30.
 */

public class TableShowImageConfig {
    public static final int STYPE_1 = 1;

    private int count;
    private int type;
    private List<String> imgs;
    private Context context;
    private ConfigModle config;

    public TableShowImageConfig(Context context, int type, List<String> imgs) {
        this.context = context;
        this.type = type;
        this.imgs = imgs;
        this.count = imgs.size();
    }

    //根据type分配样式
    public ConfigModle getConfig() {
        switch (type) {
            case STYPE_1:
                ConfigStyle1();
                break;
        }

        if (config == null) {
            config = new ConfigModle();
        }
        config.setImagesUrl(imgs);
        return config;
    }

    //配置样式
    private void ConfigStyle1() {
        switch (count) {
            case 1:
                ImageModle image1_1_1 = new ImageModle(0, null, getPxById(R.dimen.x50), getPxById(R.dimen.x50), 0, 0, 0, 0);
                GroupModle group1_1 = new GroupModle(0, 0, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                group1_1.setImageModle(image1_1_1);
                config = new ConfigModle(0, R.drawable.ic_launcher_background, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                config.setGroupModle(group1_1);
                break;
            case 2:
                ImageModle image2_1_1 = new ImageModle(1, null, 0, getPxById(R.dimen.x200), 0, 0, 0, 0);
                GroupModle group2_1 = new GroupModle(0, getPxById(R.dimen.x15), ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                group2_1.setImageModles(image2_1_1, 2);
                config = new ConfigModle(0, R.drawable.ic_launcher_background, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                config.setGroupModle(group2_1);
                break;

            case 3:
                ImageModle image3_1_1 = new ImageModle(1, null, 0, getPxById(R.dimen.x200), 0, 0, 0, 0);
                GroupModle group3_1 = new GroupModle(0, getPxById(R.dimen.x15), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                group3_1.setImageModles(image3_1_1, 3);
                config = new ConfigModle(0, R.drawable.ic_launcher_background, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                config.setGroupModle(group3_1);
                break;


            case 4:
                ImageModle image4_1_1 = new ImageModle(1, null, 0, getPxById(R.dimen.x200), 0, 0, 0, 0);
                GroupModle group4_1 = new GroupModle(0, getPxById(R.dimen.x15), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                group4_1.setImageModles(image4_1_1, 3);
                config = new ConfigModle(getPxById(R.dimen.x15), R.drawable.ic_launcher_background, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                config.setGroupModles(group4_1, 2);
                config.getGroup(0).getImage(2).setImageUrl("");
                config.getGroup(1).getImage(2).setImageUrl("");
                break;

            case 5:
                ImageModle image5_1_1 = new ImageModle(1, null, 0, getPxById(R.dimen.x200), 0, 0, 0, 0);
                GroupModle group5_1 = new GroupModle(0, getPxById(R.dimen.x15), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                group5_1.setImageModles(image5_1_1, 3);
                config = new ConfigModle(getPxById(R.dimen.x15), R.drawable.ic_launcher_background, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                config.setGroupModles(group5_1, 2);
                config.getGroup(1).getImage(2).setImageUrl("");
                break;

            case 6:
                ImageModle image6_1_1 = new ImageModle(1, null, 0, getPxById(R.dimen.x200), 0, 0, 0, 0);
                GroupModle group6_1 = new GroupModle(0, getPxById(R.dimen.x15), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                group6_1.setImageModles(image6_1_1, 3);
                config = new ConfigModle(getPxById(R.dimen.x15), R.drawable.ic_launcher_background, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                config.setGroupModles(group6_1, 2);
                break;

            case 7:
                ImageModle image7_1_1 = new ImageModle(1, null, 0, getPxById(R.dimen.x200), 0, 0, 0, 0);
                GroupModle group7_1 = new GroupModle(0, getPxById(R.dimen.x15), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                group7_1.setImageModles(image7_1_1, 3);
                config = new ConfigModle(getPxById(R.dimen.y15), R.drawable.ic_launcher_background, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                config.setGroupModles(group7_1, 3);
                config.getGroup(2).getImage(1).setImageUrl("");
                config.getGroup(2).getImage(2).setImageUrl("");
                break;
            case 8:
                ImageModle image8_1_1 = new ImageModle(1, null, 0, getPxById(R.dimen.x200), 0, 0, 0, 0);
                GroupModle group8_1 = new GroupModle(0, getPxById(R.dimen.x15), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                group8_1.setImageModles(image8_1_1, 3);
                config = new ConfigModle(getPxById(R.dimen.y15), R.drawable.ic_launcher_background, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                config.setGroupModles(group8_1, 3);
                config.getGroup(2).getImage(2).setImageUrl("");
                break;

            case 9:
                ImageModle image9_1_1 = new ImageModle(1, null, 0, getPxById(R.dimen.x200), 0, 0, 0, 0);
                GroupModle group9_1 = new GroupModle(0, getPxById(R.dimen.x15), ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                group9_1.setImageModles(image9_1_1, 3);
                config = new ConfigModle(getPxById(R.dimen.y15), R.drawable.ic_launcher_background, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0, 0, 0, 0);
                config.setGroupModles(group9_1, 3);
                break;
        }
    }


    public int getPxById(int pxId) {
        return context.getResources().getDimensionPixelSize(pxId);
    }
}
